home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Tools / Languages / MacHaskell 2.2 / ast / tc-structs.scm < prev    next >
Encoding:
Text File  |  1994-09-27  |  1.6 KB  |  64 lines  |  [TEXT/CCL2]

  1. ;;; These structures are used by the type checker for the internal
  2. ;;; representation of type information.  These are referred to in
  3. ;;; general as `ntype' structures.  Conversions are required between
  4. ;;; ast types and ntypes.
  5.  
  6. (define-struct ntype
  7.   (include ast-node))
  8.  
  9. (define-struct ntycon
  10.   (include ntype)
  11.   (predicate ntycon?)
  12.   (slots
  13.    (tycon (type def))
  14.    (args (type (list ntype)))))
  15.  
  16. (define-struct ntyvar
  17.   (include ntype)
  18.   (predicate ntyvar?)
  19.   (slots
  20.    ;; non-instantiated tyvars use #f for a value.
  21.    (value (type (maybe ntype)))
  22.    ;; could be encoded in value.
  23.    (context (type (list class)) (default ()))
  24.    (read-only? (type bool) (default #f) (bit #t))
  25.    (dict-params (type (list (tuple valdef (list (tuple class var))))))
  26.    ))
  27.  
  28. ;;; This is used only at the top level of a type during letrec type
  29. ;;; checking.
  30.  
  31. (define-struct recursive-type
  32.   (include ntype)
  33.   (predicate recursive-type?)
  34.   (slots
  35.    (type (type ntype))
  36.    (placeholders (type (list exp)))
  37.    (rsig (type (maybe ntype)))))  ; Used for polymorphic recursion.
  38.  
  39. ;;; Gtypes are generalized types which can be copied quickly & stored in
  40. ;;; interfaces.  They may contain monomorphic type variables which will not
  41. ;;; be copied.
  42.  
  43. (define-struct gtype
  44.   (include ntype)
  45.   (predicate gtype?)
  46.   (slots
  47.    (context (type (list (list class))))
  48.    (type (type ntype))))
  49.  
  50. ;;; These tyvars just index a list of pre-allocated tyvars.
  51.  
  52. (define-struct gtyvar
  53.   (include ntype)
  54.   (predicate gtyvar?)
  55.   (slots
  56.    (varnum (type int))))
  57.  
  58. (define-struct const-type
  59.   (include ntype)
  60.   (predicate const-type?)
  61.   (slots
  62.    (type (type ntype))))
  63.  
  64.